﻿using System;
using System.ComponentModel;
using ArtMath.Data;

namespace ArtMath.Component.Point
{
    /// <summary>
    /// 中点基类
    /// </summary>
    [Serializable]
    public abstract class MidPointBase : ProportionatePointBase
    {
        public MidPointBase(SketchPad pad, string name, LineBase line, bool addToList = true) : base(pad, name, ToolTypeName.zd, line, "1", addToList)
        {
        }
        [Browsable(false)]
        public override PadStringX Ratio
        {
            get
            {
                return base.Ratio;
            }

            set
            {
                base.Ratio = value;
            }
        }
        public override void ConvertType(ToolTypeName targetType)
        {
            if (targetType != ToolType) return;
            MidPointBase targetPoint = null;
            SimulateDeleted(() =>
            {
                if (Pad.CoordinateType == CoordinateSystemType.PolarCoordinate)
                {
                    targetPoint = new PMidPoint(Pad, Name, Line, false);
                }
                else
                {
                    targetPoint = new RMidPoint(Pad, Name, Line, false);
                }
            });
            afterGenerateNewType(targetPoint);
        }
    }
}
